﻿using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class ApplyJoinPageEvent : EventManager
{//带入金弹窗
    private int id;
    private string name;


    public  GetDairu tst;

    public Text text;

    public Button queding;
    public Button quxiao;

    public override void InformationSetting()
    {
        id = GameRoomModel.GetInstance().playerDic[tst.LocationIndex].userId;
        name = GameRoomModel.GetInstance().playerDic[tst.LocationIndex].name;


        if (GameData.GetInstance().JoinPageS.ContainsKey(id))
        {
            GameObject go = GameData.GetInstance()
        .JoinPageS[id].gameObject;
            if (go != null)
            {
                Destroy(go);
            }
            GameData.GetInstance().JoinPageS.Remove(id);
        }


        AddListenerToButton(quxiao, QuXiao);
        AddListenerToButton(queding, QueDing);

        text.text = string.Format("玩家{0}({1})申请带入{2}积分", name, id, tst.Score);

        GameData.GetInstance().JoinPageS.Add(id, gameObject);
    }

    void Start()
    {
        this.Open();
        InformationSetting();
    }

    public void QuXiao()
    {
        MessageManager.GetInstance().Send7160(false, tst.userId, tst.LocationIndex, tst.roomID);
        Destroy();


    }

    public void QueDing()
    {
        MessageManager.GetInstance().Send7160(true, tst.userId, tst.LocationIndex, tst.roomID);
        Destroy();

    }

    public void Destroy()
    {
        GameData.GetInstance().JoinPageS.Remove(id);
        Destroy(this.gameObject);
    }

}
